package com.ScroringSystem.backend.controller.pk;

import com.ScroringSystem.backend.common.Result;
import com.ScroringSystem.backend.pojo.UpdateScoreReq;
import com.ScroringSystem.backend.service.ContestantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@CrossOrigin
@RestController
public class ContestantController {
    private final ContestantService contestantService;

    @Autowired
    public ContestantController(ContestantService contestantService) {
        this.contestantService = contestantService;
    }

    @GetMapping("/listContestant")
    public Result listContestant() {
        return Result.success(contestantService.listContestant());
    }

    @PostMapping("/updateScore")
    public Result updateScore(@RequestBody UpdateScoreReq updateScoreReq) {
        contestantService.updateScore(updateScoreReq);
        return Result.success();
    }

    @GetMapping("/showContestant")
    public Result showContestant(){return Result.success(contestantService.showContestant());}

    @GetMapping("/countContestant")
    public Result countContestant(){return Result.success(contestantService.countContestant());}
}

